<?php

namespace app\client\controller;

use app\client\services\OrderService;

class Order extends \app\BaseController
{
    protected $middleware=['CheckClientTokenMiddleware'];

    /**
     * 获取单价
     * @return void
     */
    public function getUnitPrice(){
        api_return(200,'',Config('unitPrice')); ;
    }

    /**
     * 下单
     * @return void
     */
    public function in(){
        $p=$this->request->post();
        $p['customer_id']=$this->request->adminUid;
        OrderService::in($p);
    }

    /**
     * 订单详情
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function detail(){
        $p=$this->request->get();
        OrderService::detail($p);
    }

    /**
     * 取消订单，非新增订单（status==1）不可取消
     * @return void
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function cancel(){
        $p=$this->request->post();
        OrderService::cancel($p);
    }

    public function list(){
        $p=$this->request->get();
        $p['customer_id']=$this->request->adminUid;
        OrderService::list($p);

    }
}
